package com.ibm.cloud.banking.prod.convert;

import com.ibm.cloud.banking.prod.dto.ProductCheckDTO;
import com.ibm.cloud.banking.prod.dto.ProductInfo;
import com.ibm.cloud.banking.prod.entity.ProductInfoEntity;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.Map;

/**
 * replace desc in here
 *
 * @author HanDong
 * @date 2022/7/17
 */
@Mapper(componentModel = "spring")
public interface ProductInfoMapper {


    ProductInfoEntity dtoToEntity(ProductInfo dto);

    ProductInfo entityToDto(ProductInfoEntity entity);

   @Mappings(
           value = {
                   @Mapping(expression = "java((String)map.get(\"productNo\"))", target = "productNo"),
                   @Mapping(expression = "java((Double)map.get(\"transAmount\"))", target = "amount"),
                   @Mapping(expression = "java((Integer)map.get(\"accountCategory\"))", target = "type")
           }
   )
   ProductCheckDTO mapToDto(Map map);
}
